﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Diagnostics;

namespace 图片轮换
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Panel3D _panel3D;
        readonly TimeSpan ANIMATION_LENGTH = TimeSpan.FromSeconds(.7);

        public MainWindow()
        {
            InitializeComponent();
        }

        void OnPanel3DLoaded(object sender, RoutedEventArgs e)
        {
            // Grab a reference to the Panel3D when it loads.
            _panel3D = sender as Panel3D;
        }

        void Open_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }

        void Open_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            string url = (e.Parameter as XmlAttribute).Value;
            Process.Start(url);
        }

        void MoveForwardButtonClicked(object sender, RoutedEventArgs e)
        {
            _panel3D.MoveItems(1, true, ANIMATION_LENGTH);
        }

        void MoveBackButtonClicked(object sender, RoutedEventArgs e)
        {
            _panel3D.MoveItems(1, false, ANIMATION_LENGTH);
        }

        void PageForwardButtonClicked(object sender, RoutedEventArgs e)
        {
            _panel3D.MoveItems(3, true, ANIMATION_LENGTH);
        }

        void PageBackButtonClicked(object sender, RoutedEventArgs e)
        {
            _panel3D.MoveItems(3, false, ANIMATION_LENGTH);
        }
    }
}
